<!DOCTYPE html>
<html lang="zh-cn">
    <head>
        <meta charset="UTF-8"/>
        <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
        <title>Document</title>
        <style>
            #test p {
              float:left;
              background: #f00;
            }
            #test:after,
            #test:before {
              content:"before";
              display: table;
              background: #666;
            }
            #test:after {
              background: #0ff;
              content: "after";
            }
            #test p {
              float:left;
              background: #f00;
            }
            #test1:after,
            #test1:before {
              content:"before";
              display: block;
              background: #666;
            }
            #test1:after {
              background: #0ff;
              content: "after";
            }
        </style>
    </head>
    <body>
        <h2>display:table</h2>
        <div id="test">
            <p>浮动</p>
        </div>
        <h2>display:block</h2>
        <div id="test1">
            <p>浮动</p>
        </div>
    </body>
</html>